package com.esisa.dao.hibernate;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.esisa.utils.HibernateSessionFactory;

public abstract class AbstractHibernateDao {


	protected static Session session=null;

	public AbstractHibernateDao() {
		if(session==null){
			session=HibernateSessionFactory.openSession();
		}
	}
	protected Transaction beginTransaction() {
		return session.beginTransaction();
	}
	protected void commit() {
		session.getTransaction().commit();
	}
	protected void rollback() {
		session.getTransaction().rollback();
	}
	public void close(){
		if(session!=null){
			session.close();
		}
		session=null;
	}
}
